const router = require('koa-router')()
const auth = require('../utils/auth')

const news = require('./news')
const cookies = require('./cookies')
const session = require('./session')
const user = require('./user')

router.post('/login', async ctx => {
	// const { username, password } = ctx.request.body
	// ctx.body = {
	// 	status: 0,
	// 	data: { username, password },
	// 	msg: '登录成功'
	// }
	const token = auth.sign(ctx, ctx.request.body)
	ctx.body = `Bearer ${token}`
})


router.use('/news', news.routes())
router.use('/cookies', cookies.routes())	//cookies的使用
router.use('/session', session.routes())	//koa-session的使用
router.use('/user', user.routes())	//

module.exports = router